<?php
namespace Act\Os;
use Lib\VerifyCode\VerifyCode;
class Login extends Backend{
	public function doGet(){
		if(is_ajax()){
			return $this->ajaxLogin();
		}
		$this->display('index.php',array('page_title'=>'登录'));
	}

	private function ajaxLogin(){

	}

	public function doPost(){
		if(!VerifyCode::check()){
			$this->alert('error','验证码输入错误');
		}else{
			$user_mod = model('#User','adm_');
			if($user_info = $user_mod->login(post('user_name'),post('password'))){
				if(post('remember')){
					model('#User','adm_')->setCookieRemember($user_info['user_id'],30);
				}
				return redirect('/os/index');
			}else{
				$this->alert('error','用户名或密码错误');
			}
		}
		$this->display('index.php',array('page_title'=>'登录'));
	}
}